﻿using System.Collections.Generic;
using MLSharp.Evaluation;
using Plossum.CommandLine;

namespace MLSharp.ConsoleRunner
{
	/// <summary>
	/// Stores options passed to <see cref="ConsoleRunnerApplication"/>.
	/// </summary>
	[CommandLineManager(ApplicationName = "Flexible Test Harness", Copyright = "Copyright 2008 - TTU")]
	public class HarnessOptions
	{
		#region Public Properties

		/// <summary>
		/// The file to read data from.
		/// </summary>
		[CommandLineOption(Aliases = "input", MinOccurs = 1, MaxOccurs = 1, Description = "The Excel spreadsheet containing the data.")]
		public string InputFile { get; set; }

		/// <summary>
		/// The number of times to run the classifiers. 
		/// </summary>
		[CommandLineOption(MaxOccurs = 1, Description = "The number of iterations to run (default is 1)")]
		public int Iterations { get; set; }

		/// <summary>
		/// The classifiers to use and their options.
		/// </summary>
		[CommandLineOption(Name = "classifier", Description = "A string containing the name of the classifier to run and any options for that classifier.", MinOccurs = 1)]
		public IList<string> Classifiers { get; set; }

		/// <summary>
		/// The target attribute.
		/// </summary>
		[CommandLineOption(Aliases = "target", MinOccurs = 1, MaxOccurs = 1, Description = "The name of the attribute to predict.")]
		public string TargetAttribute { get; set; }

		/// <summary>
		/// If true, each pass within a single iteration of 10-fold CV will be parallelized, if possible.
		/// </summary>
		[CommandLineOption(Aliases = "parallel", MaxOccurs = 1, Description = "If set, the harness will attempt to run some operations in parallel.")]
		public bool RunInParallel { get; set; }

		/// <summary>
		/// The type of test harness to run.
		/// </summary>
		/// <value>The default is HarnessType.CrossValidation.</value>
		[CommandLineOption(MaxOccurs = 1, Description = "The type of test harness to run.")]
		public HarnessType HarnessType { get; set; }

		/// <summary>
		/// The filters to instantiate and apply.
		/// </summary>
		[CommandLineOption(Description = "Filters to apply to the dataset.", Aliases = "filter")]
		public IList<string> Filters { get; set; }

		/// <summary>
		/// The <see cref="IResultWriter"/> declarations.
		/// </summary>
		[CommandLineOption(Description = "Writers that process classifier output into readable results.", Aliases = "output", MinOccurs = 1)]
		public IList<string> ResultWriters { get; set; }

		#endregion

		#region Public Constructors

		/// <summary>
		/// Assigns defaults and initializes any List-based attributes.
		/// </summary>
		public HarnessOptions()
		{
			Iterations = 1;
			RunInParallel = false;
			Classifiers = new List<string>();
			HarnessType = HarnessType.CrossValidation;
			Filters = new List<string>();
			ResultWriters = new List<string>();
		}

		#endregion
	}
}
